﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
namespace Convert.CPIAMmodel
{
    public class DebtorTransFile
    {
        public DebtorTransFile(Guid guidDebtorID, DateTime dteTransDate, Guid guidStkID, string strDesc, string strGSTMarker, double shtQty, string strType, decimal decAmt, decimal decGSTAmt, long lngReceipt)
        {
            this.DebtorTransID = Guid.NewGuid();
            this.DebtHeaderID = guidDebtorID;
            this.DebtTransDate = dteTransDate;
            this.DebtTransStkID = guidStkID;
            this.DebtTransDescpt = strDesc;
            this.DebtTransGSTMarker = strGSTMarker;
            this.DebtTransQty = shtQty;
            this.DebtTransType = strType;
            this.DebtTransAmt = decAmt;
            this.DebtTransGSTAmt = decGSTAmt;
            this.DebtTransReceiptID = lngReceipt;
            this.DebtIssuingStoreID = 1;
            this.DebtTransPointChk = -1;
        }
        private Guid _DebtorTransID;

        public Guid DebtorTransID
        {
            get { return _DebtorTransID; }
            set { _DebtorTransID = value; }
        }
        private Guid _DebtHeaderID;

        public Guid DebtHeaderID
        {
            get { return _DebtHeaderID; }
            set { _DebtHeaderID = value; }
        }
        private int _DebtIssuingStoreID;

        public int DebtIssuingStoreID
        {
            get { return _DebtIssuingStoreID; }
            set { _DebtIssuingStoreID = value; }
        }
        private DateTime _DebtTransDate;

        public DateTime DebtTransDate
        {
            get { return _DebtTransDate; }
            set { _DebtTransDate = value; }
        }
        private Guid _DebtTransStkID;

        public Guid DebtTransStkID
        {
            get { return _DebtTransStkID; }
            set { _DebtTransStkID = value; }
        }
        private string _DebtTransDescpt;

        public string DebtTransDescpt
        {
            get { return _DebtTransDescpt; }
            set
            {
                _DebtTransDescpt = string.IsNullOrWhiteSpace(value) ? "" : value;
                if (_DebtTransDescpt.Length > 100)
                    _DebtTransDescpt = _DebtTransDescpt.Substring(0, 100);
            }
        }
        private string _DebtTransGSTMarker;

        public string DebtTransGSTMarker
        {
            get { return _DebtTransGSTMarker; }
            set
            {
                _DebtTransGSTMarker = string.IsNullOrWhiteSpace(value) ? "" : value;
                if (_DebtTransGSTMarker.Length > 1)
                    _DebtTransGSTMarker = _DebtTransGSTMarker.Substring(0, 1);
            }
        }
        private double _DebtTransQty;

        public double DebtTransQty
        {
            get { return _DebtTransQty; }
            set { _DebtTransQty = value; }
        }
        private string _DebtTransType;

        public string DebtTransType
        {
            get { return _DebtTransType; }
            set
            {
                _DebtTransType = string.IsNullOrWhiteSpace(value) ? "" : value;
                if (_DebtTransType.Length > 1)
                    _DebtTransType = _DebtTransType.Substring(0, 1);
            }
        }
        private decimal _DebtTransAmt;

        public decimal DebtTransAmt
        {
            get { return _DebtTransAmt; }
            set { _DebtTransAmt = value; }
        }
        private decimal _DebtTransGSTAmt;

        public decimal DebtTransGSTAmt
        {
            get { return _DebtTransGSTAmt; }
            set { _DebtTransGSTAmt = value; }
        }
        private long _DebtTransReceiptID;

        public long DebtTransReceiptID
        {
            get { return _DebtTransReceiptID; }
            set { _DebtTransReceiptID = value; }
        }
        private int _DebtTransPointChk;

        public int DebtTransPointChk
        {
            get { return _DebtTransPointChk; }
            set { _DebtTransPointChk = value; }
        }

        public static void SaveDebtorTransFileToDataTable(DebtorTransFile debtorTransFile, DataTable DebtorTransFileDT)
        {
            DebtorTransFileDT.Rows.Add(
            debtorTransFile.DebtorTransID,
            debtorTransFile.DebtHeaderID,
            debtorTransFile.DebtIssuingStoreID,
            debtorTransFile.DebtTransDate,
            debtorTransFile.DebtTransStkID,
            debtorTransFile.DebtTransDescpt,
            debtorTransFile.DebtTransGSTMarker,
            debtorTransFile.DebtTransQty,
            debtorTransFile.DebtTransType,
            debtorTransFile.DebtTransAmt,
            debtorTransFile.DebtTransGSTAmt,
            debtorTransFile.DebtTransReceiptID,
            debtorTransFile.DebtTransPointChk);
        }

    }

    public class LaybyContracts 
    {
        public LaybyContracts(Guid LaybyHeaderID, Guid ClientID, string LaybyStatus, DateTime CreatedDate, DateTime FinishDate, long LaybyID)
        {
            this.ClientID = ClientID;
            this.LaybyContractID = LaybyHeaderID;
            this.LaybyStatus = LaybyStatus;
            this.LaybyTotal=0;
            this.LaybyCustDepositAmt=0;
            this.LaybyCustDepositPerc=0;
            this.LaybyPaymentsTotal=0;
            this.LaybyRemainingBal=0;
            this.LaybyFinialReceipt=0;
            this.LaybyStarted = CreatedDate;
            this.LaybyFinish = FinishDate;
            this.LaybyOLDPOSID = LaybyID;
        }
        public Guid LaybyContractID{get; set;}
        public Guid ClientID{get; set;}
        public string LaybyStatus{get; set;}
        public decimal LaybyTotal{get; set;} 
        public decimal LaybyCustDepositAmt{get; set;} 
        public decimal LaybyCustDepositPerc{get; set;} 
        public decimal LaybyPaymentsTotal{get; set;} 
        public decimal LaybyRemainingBal{get; set;} 
        public int LaybyFinialReceipt{get; set;} 
        public DateTime LaybyStarted{get; set;} 
        public DateTime LaybyFinish{get; set;}
        public long LaybyOLDPOSID {get; set; }

        public static void SaveLaybyContractsToDataTable(LaybyContracts laybyContracts, DataTable LaybyContractsFileDT)
        {
            LaybyContractsFileDT.Rows.Add(
            laybyContracts.LaybyContractID,
            laybyContracts.ClientID,
            laybyContracts.LaybyStatus,
            laybyContracts.LaybyTotal,
            laybyContracts.LaybyCustDepositAmt,
            laybyContracts.LaybyCustDepositPerc,
            laybyContracts.LaybyPaymentsTotal,
            laybyContracts.LaybyRemainingBal,
            laybyContracts.LaybyFinialReceipt,
            laybyContracts.LaybyStarted,
            laybyContracts.LaybyFinish,
            laybyContracts.LaybyOLDPOSID);
        }
    }

    public class LaybyTransFile
    {
        public LaybyTransFile(Guid ContractID, DateTime dteTransDate, string strItemCode, int intStkNo, string strDesc,
        Int16 shtQty, string strType, decimal decTransAmt, decimal decGSTAmt, string strMarker, decimal decSellPrice, long lngOLDPOSReceipt)
        {
            this.LaybyTransID = Guid.NewGuid();
            this.LaybyTransID = LaybyTransID;
            this.LaybyContractID = ContractID;
            this.LaybyTransDate = dteTransDate;
            this.LaybyItemCode = strItemCode;
            this.LaybyStkNumber = intStkNo;
            this.LaybyDeptNo = 0;
            this.LaybyTransDescpt = strDesc;
            this.LaybyTransClerk = "N/A";
            this.LaybyTransQty = shtQty;
            this.LaybyTransType = strType;
            this.LaybyTransAmt = decTransAmt;
            this.LaybyGSTAmt = decGSTAmt;
            this.LaybyGSTMarker = strMarker;
            this.LaybySellPrice = decSellPrice;
            this.LaybyReceiptNo = lngOLDPOSReceipt;
        }
        public Guid LaybyTransID {get; set;}
        public Guid LaybyContractID {get; set;} 
        public DateTime LaybyTransDate {get; set;} 
        public string LaybyItemCode {get; set;}  
        public int LaybyStkNumber {get; set;}
        public int LaybyDeptNo {get; set;} 
        public string LaybyTransDescpt {get; set;}
        public string LaybyTransClerk {get; set;} 
        public Int16 LaybyTransQty {get; set;} 
        public string LaybyTransType {get; set;} 
        public decimal LaybyTransAmt {get; set;} 
        public decimal LaybyGSTAmt {get; set;}
        public string LaybyGSTMarker {get; set;}
        public decimal LaybySellPrice {get; set;}
        public long LaybyReceiptNo { get; set; }

        public static void SaveLaybyTransToDataTable(LaybyTransFile LaybyTrans, DataTable LaybyTransFileDT)
        {
            LaybyTransFileDT.Rows.Add(
            LaybyTrans.LaybyTransID,
            LaybyTrans.LaybyContractID,
            LaybyTrans.LaybyTransDate,
            LaybyTrans.LaybyItemCode,
            LaybyTrans.LaybyStkNumber,
            LaybyTrans.LaybyDeptNo,
            LaybyTrans.LaybyTransDescpt,
            LaybyTrans.LaybyTransClerk,
            LaybyTrans.LaybyTransQty,
            LaybyTrans.LaybyTransType,
            LaybyTrans.LaybyTransAmt,
            LaybyTrans.LaybyGSTAmt,
            LaybyTrans.LaybyGSTMarker,
            LaybyTrans.LaybySellPrice,
            LaybyTrans.LaybyReceiptNo);
        }
    }

    public class DebtorHeader
    {
        public DebtorHeader(Guid DebtorHeaderID, Guid ClientID, decimal DebtCurrBal, decimal DebtTotalBal, decimal decOpenBal, decimal dec30DayBal, decimal dec60DayBal, decimal dec90DayBal, decimal DebtCredLimit, string DebtGroup, long LngExternDebtorID)
        {
            this.DebtorHeaderID = DebtorHeaderID;
            this.ClientID = ClientID;
            this.DebtIssuingStoreID = 1;
            this.DebtAccDesc = "Primary Account (Default)";
            this.DebtorAccCreated = DateTime.Now;
            this.DebtorAccCreatedBy = "System";
            this.DebtAccStatus = "A";
            this.DebtOpenBal = decOpenBal;
            this.DebtCurrBal = DebtCurrBal;
            this.DebtTotalBal = DebtTotalBal;
            this.Debt30DayBal = dec30DayBal;
            this.Debt60DayBal = dec60DayBal;
            this.Debt90DayBal = dec90DayBal;
            this.DebtCredLimit = DebtCredLimit;
            this.DebtDisc = 0;
            this.DebtGroup = DebtGroup;
            this.DebtDiscAll = false;
            this.DebtSurcharge = true;
            this.DebtPrintStat = true;
            this.DebtEmailStatment = false;
            this.DebtMaskScripts = false;
            this.ExternDebtorID = LngExternDebtorID;
        }

        private Guid _DebtorHeaderID;

        public Guid DebtorHeaderID
        {
            get { return _DebtorHeaderID; }
            set { _DebtorHeaderID = value; }
        }
        private Guid _ClientID;

        public Guid ClientID
        {
            get { return _ClientID; }
            set { _ClientID = value; }
        }
        private Int16 _DebtIssuingStoreID;

        public Int16 DebtIssuingStoreID
        {
            get { return _DebtIssuingStoreID; }
            set { _DebtIssuingStoreID = value; }
        }
        private String _DebtAccDesc;

        public String DebtAccDesc
        {
            get { return _DebtAccDesc; }
            set
            {
                _DebtAccDesc = string.IsNullOrWhiteSpace(value) ? "" : value;
                if (_DebtAccDesc.Length > 200)
                    _DebtAccDesc = _DebtAccDesc.Substring(0, 200);
            }
        }
        private DateTime _DebtorAccCreated;

        public DateTime DebtorAccCreated
        {
            get { return _DebtorAccCreated; }
            set { _DebtorAccCreated = value; }
        }
        private String _DebtorAccCreatedBy;

        public String DebtorAccCreatedBy
        {
            get { return _DebtorAccCreatedBy; }
            set
            {
                _DebtorAccCreatedBy = string.IsNullOrWhiteSpace(value) ? "" : value;
                if (_DebtorAccCreatedBy.Length > 100)
                    _DebtorAccCreatedBy = _DebtorAccCreatedBy.Substring(0, 100);
            }
        }
        private String _DebtAccStatus;

        public String DebtAccStatus
        {
            get { return _DebtAccStatus; }
            set
            {
                _DebtAccStatus = string.IsNullOrWhiteSpace(value) ? "" : value;
                if (_DebtAccStatus.Length > 1)
                    _DebtAccStatus = _DebtAccStatus.Substring(0, 1);
            }
        }
        private Decimal _DebtOpenBal;

        public Decimal DebtOpenBal
        {
            get { return _DebtOpenBal; }
            set { _DebtOpenBal = value; }
        }
        private Decimal _DebtCurrBal;

        public Decimal DebtCurrBal
        {
            get { return _DebtCurrBal; }
            set { _DebtCurrBal = value; }
        }
        private Decimal _Debt30DayBal;

        public Decimal Debt30DayBal
        {
            get { return _Debt30DayBal; }
            set { _Debt30DayBal = value; }
        }
        private Decimal _Debt60DayBal;

        public Decimal Debt60DayBal
        {
            get { return _Debt60DayBal; }
            set { _Debt60DayBal = value; }
        }
        private Decimal _Debt90DayBal;

        public Decimal Debt90DayBal
        {
            get { return _Debt90DayBal; }
            set { _Debt90DayBal = value; }
        }
        private Decimal _DebtTotalBal;

        public Decimal DebtTotalBal
        {
            get { return _DebtTotalBal; }
            set { _DebtTotalBal = value; }
        }
        private Decimal _DebtCredLimit;

        public Decimal DebtCredLimit
        {
            get { return _DebtCredLimit; }
            set { _DebtCredLimit = value; }
        }
        private Decimal _DebtDisc;

        public Decimal DebtDisc
        {
            get { return _DebtDisc; }
            set { _DebtDisc = value; }
        }
        private String _DebtGroup;

        public String DebtGroup
        {
            get { return _DebtGroup; }
            set
            {
                _DebtGroup = string.IsNullOrWhiteSpace(value) ? "" : value;
                if (_DebtGroup.Length > 50)
                    _DebtGroup = _DebtGroup.Substring(0, 50);
            }
        }
        private Boolean _DebtDiscAll;

        public Boolean DebtDiscAll
        {
            get { return _DebtDiscAll; }
            set { _DebtDiscAll = value; }
        }
        private Boolean _DebtSurcharge;

        public Boolean DebtSurcharge
        {
            get { return _DebtSurcharge; }
            set { _DebtSurcharge = value; }
        }
        private Boolean _DebtPrintStat;

        public Boolean DebtPrintStat
        {
            get { return _DebtPrintStat; }
            set { _DebtPrintStat = value; }
        }
        private Boolean _DebtEmailStatment;

        public Boolean DebtEmailStatment
        {
            get { return _DebtEmailStatment; }
            set { _DebtEmailStatment = value; }
        }
        private Boolean _DebtMaskScripts;

        public Boolean DebtMaskScripts
        {
            get { return _DebtMaskScripts; }
            set { _DebtMaskScripts = value; }
        }
        private long _ExternDebtorID;

        public long ExternDebtorID
        {
            get { return _ExternDebtorID; }
            set { _ExternDebtorID = value; }
        }

        public static void SaveDebtorHeaderDataTable(DebtorHeader debtorHeader, DataTable DebtorHeaderDT)
        {
            DebtorHeaderDT.Rows.Add(
                debtorHeader.DebtorHeaderID,
                debtorHeader.ClientID,
                debtorHeader.DebtIssuingStoreID,
                debtorHeader.DebtAccDesc,
                debtorHeader.DebtorAccCreated,
                debtorHeader.DebtorAccCreatedBy,
                debtorHeader.DebtAccStatus,
                debtorHeader.DebtOpenBal,
                debtorHeader.DebtCurrBal,
                debtorHeader.Debt30DayBal,
                debtorHeader.Debt60DayBal,
                debtorHeader.Debt90DayBal,
                debtorHeader.DebtTotalBal,
                debtorHeader.DebtCredLimit,
                debtorHeader.DebtDisc,
                debtorHeader.DebtGroup,
                debtorHeader.DebtDiscAll,
                debtorHeader.DebtSurcharge,
                debtorHeader.DebtPrintStat,
                debtorHeader.DebtEmailStatment,
                debtorHeader.DebtMaskScripts,
                debtorHeader.ExternDebtorID);
        }
    }
    public class Client
    {
        public Client(Guid ClientID, int ClientNo, string ClientCardID, Int16 ClientIssuingStoreID, DateTime ClientCreated, string ClientCreatedBy, string ClientSurname, string ClientFirstName,
                    string ClientSearchMarker, string ClientSalu, string ClientSex, DateTime ClientBirthDate, string ClientPostalAddress, string ClientPostalSuburb, string ClientPostalState, string ClientPostalPCode,
                    string ClientHomeAddress, string ClientHomeSuburb, string ClientHomeState, string ClientHomePCode, string ClientPhoneNumber, string ClientFaxNumber, string ClientMobileNumber, string ClientEmailAddress,
                    Boolean ClientSendMail, DateTime ClientEmailLastChecked, string ClientStatus, string ClientAcType, string ClientIDType, string ClientIDDetails)
        {
            this.ClientID=ClientID;
            this.ClientNo=ClientNo;
            this.ClientCardID=ClientCardID;
            this.ClientIssuingStoreID=ClientIssuingStoreID;
            this.ClientCreated=ClientCreated;
            this.ClientCreatedBy=ClientCreatedBy;
            this.ClientSurname=ClientSurname;
            this.ClientFirstName=ClientFirstName;
            this.ClientSearchMarker=ClientSearchMarker;
            this.ClientSalu=ClientSalu;
            this.ClientSex=ClientSex;
            this.ClientBirthDate=ClientBirthDate;
            this.ClientPostalAddress=ClientPostalAddress;
            this.ClientPostalSuburb=ClientPostalSuburb;
            this.ClientPostalState=ClientPostalState;
            this.ClientPostalPCode=ClientPostalPCode;
            this.ClientHomeAddress=ClientHomeAddress;
            this.ClientHomeSuburb=ClientHomeSuburb;
            this.ClientHomeState=ClientHomeState;
            this.ClientHomePCode=ClientHomePCode;
            this.ClientPhoneNumber=ClientPhoneNumber;
            this.ClientFaxNumber=ClientFaxNumber;
            this.ClientMobileNumber=ClientMobileNumber;
            this.ClientMobileNumber=ClientMobileNumber;
            this.ClientEmailAddress=ClientEmailAddress;
            this.ClientSendMail=ClientSendMail;
            this.ClientEmailLastChecked=ClientEmailLastChecked;
            this.ClientStatus=ClientStatus;
            this.ClientAcType=ClientAcType;
            this.ClientIDType=ClientIDType;
            this.ClientIDDetails = ClientIDDetails;
        }

        private Guid _ClientID;

        public Guid ClientID
        {
            get { return _ClientID; }
            set { _ClientID = value; }
        }

        private int _ClientNo;

        public int ClientNo
        {
            get { return _ClientNo; }
            set { _ClientNo = value; }
        }

        private string _ClientCardID;

        public string ClientCardID
        {
            get { return _ClientCardID; }
            set
            {
                _ClientCardID = string.IsNullOrWhiteSpace(value) ? "" : value;
                if (_ClientCardID.Length > 100)
                    _ClientCardID = _ClientCardID.Substring(0, 100);
            }
        }
        private Int16 _ClientIssuingStoreID;

        public Int16 ClientIssuingStoreID
        {
            get { return _ClientIssuingStoreID; }
            set { _ClientIssuingStoreID = value; }
        }
        private DateTime _ClientCreated;

        public DateTime ClientCreated
        {
            get { return _ClientCreated; }
            set { _ClientCreated = value; }
        }
        private string _ClientCreatedBy;

        public string ClientCreatedBy
        {
            get { return _ClientCreatedBy; }
            set
            {
                _ClientCreatedBy = string.IsNullOrWhiteSpace(value) ? "" : value;
                if (_ClientCreatedBy.Length > 100)
                    _ClientCreatedBy = _ClientCreatedBy.Substring(0, 100);
            }
        }
        private string _ClientSurname;

        public string ClientSurname
        {
            get { return _ClientSurname; }
            set
            {
                _ClientSurname = string.IsNullOrWhiteSpace(value) ? "" : value;
                if (_ClientSurname.Length > 100)
                    _ClientSurname = _ClientSurname.Substring(0, 100);
            }
        }
        private string _ClientFirstName;

        public string ClientFirstName
        {
            get { return _ClientFirstName; }
            set
            {
                _ClientFirstName = string.IsNullOrWhiteSpace(value) ? "" : value;
                if (_ClientFirstName.Length > 100)
                    _ClientFirstName = _ClientFirstName.Substring(0, 100);
            }
        }
        private string _ClientSearchMarker;

        public string ClientSearchMarker
        {
            get { return _ClientSearchMarker; }
            set
            {
                _ClientSearchMarker = string.IsNullOrWhiteSpace(value) ? "" : value;
                if (_ClientSearchMarker.Length > 2)
                    _ClientSearchMarker = _ClientSearchMarker.Substring(0, 2);
            }
        }
        private string _ClientSalu;

        public string ClientSalu
        {
            get { return _ClientSalu; }
            set
            {
                _ClientSalu = string.IsNullOrWhiteSpace(value) ? "" : value;
                if (_ClientSalu.Length > 50)
                    _ClientSalu = _ClientSalu.Substring(0, 50);
            }
        }
        private string _ClientSex;

        public string ClientSex
        {
            get { return _ClientSex; }
            set
            {
                _ClientSex = string.IsNullOrWhiteSpace(value) ? "" : value;
                if (_ClientSex.Length > 50)
                    _ClientSex = _ClientSex.Substring(0, 50);
            }
        }
        private DateTime _ClientBirthDate;

        public DateTime ClientBirthDate
        {
            get { return _ClientBirthDate; }
            set { _ClientBirthDate = value; }
        }
        private string _ClientPostalAddress;

        public string ClientPostalAddress
        {
            get { return _ClientPostalAddress; }
            set
            {
                _ClientPostalAddress = string.IsNullOrWhiteSpace(value) ? "" : value;
                if (_ClientPostalAddress.Length > 255)
                    _ClientPostalAddress = _ClientPostalAddress.Substring(0, 255);
            }
        }
        private string _ClientPostalSuburb;

        public string ClientPostalSuburb
        {
            get { return _ClientPostalSuburb; }
            set
            {
                _ClientPostalSuburb = string.IsNullOrWhiteSpace(value) ? "" : value;
                if (_ClientPostalSuburb.Length > 100)
                    _ClientPostalSuburb = _ClientPostalSuburb.Substring(0, 100);
            }
        }
        private string _ClientPostalState;

        public string ClientPostalState
        {
            get { return _ClientPostalState; }
            set
            {
                _ClientPostalState = string.IsNullOrWhiteSpace(value) ? "" : value;
                if (_ClientPostalState.Length > 50)
                    _ClientPostalState = _ClientPostalState.Substring(0, 50);
            }
        }
        private string _ClientPostalPCode;

        public string ClientPostalPCode
        {
            get { return _ClientPostalPCode; }
            set
            {
                _ClientPostalPCode = string.IsNullOrWhiteSpace(value) ? "" : value;
                if (_ClientPostalPCode.Length > 50)
                    _ClientPostalPCode = _ClientPostalPCode.Substring(0, 50);
            }
        }
        private string _ClientHomeAddress;

        public string ClientHomeAddress
        {
            get { return _ClientHomeAddress; }
            set
            {
                _ClientHomeAddress = string.IsNullOrWhiteSpace(value) ? "" : value;
                if (_ClientHomeAddress.Length > 255)
                    _ClientHomeAddress = _ClientHomeAddress.Substring(0, 255);
            }
        }
        private string _ClientHomeSuburb;

        public string ClientHomeSuburb
        {
            get { return _ClientHomeSuburb; }
            set
            {
                _ClientHomeSuburb = string.IsNullOrWhiteSpace(value) ? "" : value;
                if (_ClientHomeSuburb.Length > 100)
                    _ClientHomeSuburb = _ClientHomeSuburb.Substring(0, 100);
            }
        }
        private string _ClientHomeState;

        public string ClientHomeState
        {
            get { return _ClientHomeState; }
            set
            {
                _ClientHomeState = string.IsNullOrWhiteSpace(value) ? "" : value;
                if (_ClientHomeState.Length > 50)
                    _ClientHomeState = _ClientHomeState.Substring(0, 50);
            }
        }
        private string _ClientHomePCode;

        public string ClientHomePCode
        {
            get { return _ClientHomePCode; }
            set
            {
                _ClientHomePCode = string.IsNullOrWhiteSpace(value) ? "" : value;
                if (_ClientHomePCode.Length > 50)
                    _ClientHomePCode = _ClientHomePCode.Substring(0, 50);
            }
        }
        private string _ClientPhoneNumber;

        public string ClientPhoneNumber
        {
            get { return _ClientPhoneNumber; }
            set
            {
                _ClientPhoneNumber = string.IsNullOrWhiteSpace(value) ? "" : value;
                if (_ClientPhoneNumber.Length > 50)
                    _ClientPhoneNumber = _ClientPhoneNumber.Substring(0, 50);
            }
        }
        private string _ClientFaxNumber;

        public string ClientFaxNumber
        {
            get { return _ClientFaxNumber; }
            set
            {
                _ClientFaxNumber = string.IsNullOrWhiteSpace(value) ? "" : value;
                if (_ClientFaxNumber.Length > 50)
                    _ClientFaxNumber = _ClientFaxNumber.Substring(0, 50);
            }
        }
        private string _ClientMobileNumber;

        public string ClientMobileNumber
        {
            get { return _ClientMobileNumber; }
            set
            {
                _ClientMobileNumber = string.IsNullOrWhiteSpace(value) ? "" : value;
                if (_ClientMobileNumber.Length > 50)
                    _ClientMobileNumber = _ClientMobileNumber.Substring(0, 50);
            }
        }
        private string _ClientEmailAddress;

        public string ClientEmailAddress
        {
            get { return _ClientEmailAddress; }
            set
            {
                _ClientEmailAddress = string.IsNullOrWhiteSpace(value) ? "" : value;
                if (_ClientEmailAddress.Length > 100)
                    _ClientEmailAddress = _ClientEmailAddress.Substring(0, 100);
            }
        }
        private Boolean _ClientSendMail;

        public Boolean ClientSendMail
        {
            get { return _ClientSendMail; }
            set { _ClientSendMail = value; }
        }
        private DateTime _ClientEmailLastChecked;

        public DateTime ClientEmailLastChecked
        {
            get { return _ClientEmailLastChecked; }
            set { _ClientEmailLastChecked = value; }
        }
        private string _ClientStatus;

        public string ClientStatus
        {
            get { return _ClientStatus; }
            set
            {
                _ClientStatus = string.IsNullOrWhiteSpace(value) ? "" : value;
                if (_ClientStatus.Length > 1)
                    _ClientStatus = _ClientStatus.Substring(0, 1);
            }
        }
        private string _ClientAcType;

        public string ClientAcType
        {
            get { return _ClientAcType; }
            set
            {
                _ClientAcType = string.IsNullOrWhiteSpace(value) ? "" : value;
                if (_ClientAcType.Length > 50)
                    _ClientAcType = _ClientAcType.Substring(0, 50);
            }
        }
        private string _ClientIDType;

        public string ClientIDType
        {
            get { return _ClientIDType; }
            set
            {
                _ClientIDType = string.IsNullOrWhiteSpace(value) ? "" : value;
                if (_ClientIDType.Length > 50)
                    _ClientIDType = _ClientIDType.Substring(0, 50);
            }
        }
        private string _ClientIDDetails;

        public string ClientIDDetails
        {
            get { return _ClientIDDetails; }
            set
            {
                _ClientIDDetails = string.IsNullOrWhiteSpace(value) ? "" : value;
                if (_ClientIDDetails.Length > 50)
                    _ClientIDDetails = _ClientIDDetails.Substring(0, 50);
            }
        }

        public static void SaveClientToDataTable(Client client, DataTable ClientDT)
        {
            ClientDT.Rows.Add(client.ClientID,
            client.ClientNo,
            client.ClientCardID,
            client.ClientIssuingStoreID,
            client.ClientCreated,
            client.ClientCreatedBy,
            client.ClientSurname,
            client.ClientFirstName,
            client.ClientSearchMarker,
            client.ClientSalu,
            client.ClientSex,
            client.ClientBirthDate,
            client.ClientPostalAddress,
            client.ClientPostalSuburb,
            client.ClientPostalState,
            client.ClientPostalPCode,
            client.ClientHomeAddress,
            client.ClientHomeSuburb,
            client.ClientHomeState,
            client.ClientHomePCode,
            client.ClientPhoneNumber,
            client.ClientFaxNumber,
            client.ClientMobileNumber,
            client.ClientEmailAddress,
            client.ClientSendMail,
            client.ClientEmailLastChecked,
            client.ClientStatus,
            client.ClientAcType,
            client.ClientIDType,
            client.ClientIDDetails);
        }
    }

    public class ClubMembers
    {
        public ClubMembers(Guid ClientID, decimal ClubDollarsAchd, decimal ClubDollarsSpent, decimal ClubTotVouchers, decimal ClubDollarsRem, Boolean ClubWelcomeSent, Boolean ClubCardIssued)
        {
            this.ClientID = ClientID;
            this.ClubCardIssued = ClubCardIssued;
            this.ClubDollarsAchd = ClubDollarsAchd;
            this.ClubDollarsRem = ClubDollarsRem;
            this.ClubDollarsSpent = ClubDollarsSpent;
            this.ClubTotVouchers = ClubTotVouchers;
            this.ClubWelcomeSent = ClubWelcomeSent;
        }

        private Guid _ClientID;

        public Guid ClientID
        {
            get { return _ClientID; }
            set { _ClientID = value; }
        }
        private decimal _ClubDollarsAchd;

        public decimal ClubDollarsAchd
        {
            get { return _ClubDollarsAchd; }
            set { _ClubDollarsAchd = value; }
        }
        private decimal _ClubDollarsSpent;

        public decimal ClubDollarsSpent
        {
            get { return _ClubDollarsSpent; }
            set { _ClubDollarsSpent = value; }
        }
        private decimal _ClubTotVouchers;

        public decimal ClubTotVouchers
        {
            get { return _ClubTotVouchers; }
            set { _ClubTotVouchers = value; }
        }
        private decimal _ClubDollarsRem;

        public decimal ClubDollarsRem
        {
            get { return _ClubDollarsRem; }
            set { _ClubDollarsRem = value; }
        }
        private Boolean _ClubWelcomeSent;

        public Boolean ClubWelcomeSent
        {
            get { return _ClubWelcomeSent; }
            set { _ClubWelcomeSent = value; }
        }
        private Boolean _ClubCardIssued;

        public Boolean ClubCardIssued
        {
            get { return _ClubCardIssued; }
            set { _ClubCardIssued = value; }
        }

        public static void SaveClubMembersToDataTable(ClubMembers clubMembers, DataTable ClubMembersDT)
        {
            ClubMembersDT.Rows.Add(clubMembers.ClientID, clubMembers.ClubDollarsAchd,clubMembers.ClubDollarsSpent,clubMembers.ClubTotVouchers,clubMembers.ClubDollarsRem,clubMembers.ClubWelcomeSent,clubMembers.ClubCardIssued);
        }

    }

    public class Patients
    {
        public Patients(Guid ClientID)
        {
            this.ClientID = ClientID;
        }

        private Guid _ClientID;

        public Guid ClientID
        {
            get { return _ClientID; }
            set { _ClientID = value; }
        }

        public static void SavePatientsToDataTable(Patients patients, DataTable PatientsDT)
        {
            PatientsDT.Rows.Add(patients.ClientID);
        }
    }

    public class DebtorHeaderDetail
    {
        public Guid DebtorHeaderID;
        public Guid ClientID;
        public int ClientNo;
        public decimal Balance;
    }

    public class DaysBalance
    {
        public decimal CurrentBalance;
        public decimal Days30Balance;
        public decimal Days60Balance;
        public decimal Days90Balance;
        public decimal TotalBalance;
        public decimal payment;
    }
}
